FROM python:3.11 as build
WORKDIR /app
COPY . .
RUN mkdir /root/.pip \
 && echo "[global]" >> /root/.pip/pip.conf \
 && echo "index-url = https://mirrors.aliyun.com/pypi/simple" >> /root/.pip/pip.conf \
 && echo "trusted-host = mirrors.aliyun.com" >> /root/.pip/pip.conf \
 && python -m pip install --upgrade pip \
 && python -m pip install -r requirements.txt \
 && python -m pip install pyinstaller
RUN pyinstaller -F task-agent.py

FROM ubuntu:22.04
WORKDIR /app
COPY --from=build /app/dist/task-agent /app/task-agent
COPY config.json /app
CMD ["/app/task-agent"]